<?php
$html = '<html>
<head></head>
<body>
<form action = "" method = "post">
<input type = "text" name = "user"/>

<input type = "submit" value = "ok"/>
</form>
</body>
</html>
';
$key = 'abc';
if(!isset($_COOKIE['login'])){
	if(isset($_POST['user'])){
		if($_POST['user'] == 'duytrung'){
			$login = 1;
			require ('Cookie.php');
			$cookie = new Cookie();
			$cookie->setCookie('duytrung', $key,3600);
				
			echo 'dang nhap thanh cong';
		}else{
			echo $html;
		}
	}else{
		echo $html;
	}
}else{
	require 'Authenticat.php';
	$au = new authenticat();
	$cookie = $au->getCookie();
	$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
	$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
	$arr2 = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, 'abc',$_COOKIE['login'], MCRYPT_MODE_ECB, $iv);
	$flag = $au->checkLogin($key);
	if($flag == true){
		echo 'vao thang trang chu';
	}else{
		echo $html;
			
	}
}

